﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;
using OneShoppingDAL;
/// <summary>
///列表页面的基类
/// </summary>
public class BaseListPage : BasePage
{
    public string Condition
    {
        get
        {
            if (ViewState["Condition"] == null) return "";
            else return ViewState["Condition"].ToString();
        }
        set
        {
            ViewState["Condition"] = value;
        }

    }//查询条件

    public int PageIndex;//当前页码

    public int PageSize;//每页大小

    public string TableName;//数据表名

    public string Pk;//数据表主键


    //绑定分页控件
    public void BindAspNetPager(ref AspNetPager pager)
    {

        pager.PageSize = PageSize;
        pager.CurrentPageIndex = PageIndex;
        pager.RecordCount = SqlUtility.GetInstance().CommonSelectDataCountByCondition
            (TableName, Condition);
    }
    //绑定数据源控件
    public void BindData(ref Repeater rpt)
    {
        var list = SqlUtility.GetInstance().CommonSelectDataByPageIndex
            (TableName, null, Pk, Condition, PageIndex, PageSize);
        rpt.DataSource = list;
        rpt.DataBind();
    }

    //根据条件绑定数据源控件
    public void BindData(ref Repeater rpt, string condition)
    {
        var list = SqlUtility.GetInstance().CommonSelectDataByPageIndex
            (TableName, condition, Pk, Condition, PageIndex, PageSize);
        rpt.DataSource = list;
        rpt.DataBind();
    }
}